$(function(){
	var swiper1 = new Swiper('.sw1', {
        slidesPerView:11.4,
        freeMode : true,
        freeModeMomentumRatio: 0.5,
        direction: 'vertical'
    });
    swiper1.container.on("click", function(){
        var slide = swiper1.slides.eq(swiper1.clickedIndex);
        slide.addClass("active").siblings().removeClass("active");
        swiper2.slideTo(swiper1.clickedIndex);//slideTo 设置为true则点击slide时会在这个slide产生过渡

    })
            
    var swiper2 = new Swiper('.sw2', {
    	pagination: '.swiper-pagination',
    	paginationClickable: true,
        autoHeight: true,
        direction: 'vertical',
        onInit: function(swiper2) { 
            $.ajax({
                type: "GET",
                url:"../json/fl.json",
                dataType: 'json',
                success:function(data){
                    if(swiper2.activeIndex == 0){
                        data = data.filter(function(v){
                            return v.number ==swiper2.activeIndex;
                        });
                        var str = template("moban", {arr:data});
                        $('.ab').eq(swiper2.activeIndex).html(str);
                    }
                }
            })
        },
        onSlideChangeEnd: function(swiper2) {
    		swiper1.clickedIndex = swiper2.activeIndex;
            swiper1.slides.eq(swiper2.activeIndex).trigger('click');
            $.ajax({
                type: "GET",
                url:"../json/fl.json",
                dataType: 'json',
                success: function(data){
                    if(swiper2.activeIndex != 0){
                        data = data.filter(function(v){
                            return v.number ==swiper2.activeIndex;
                        });
                        var str = template("moban", {arr:data});
                        $('.ab').eq(swiper2.activeIndex).html(str);
                    }
                }
            });
    	}
    });
    $('.fl-search').click(function(){
        location.href="search.html";
    })
})